$(function(){
    var setNumber = 0;
    var destination;
    var time;
    var likeType = new Array();
    var newLikeType = new Array("测试","测试","测试","测试","测试","测试");
    var inputTrueFlag = true;
    $( "#time" ).timeDropper();
    $(".conditions-input").click(function(){  //文字输入控制
        if(inputTrueFlag){  //输入校验
            if(setNumber==0){   //目的地
                destination = $(".input-text").val();
                $(".user-step-1 p").html(destination);
                $(".user-step-1").removeAttr("hidden");
                setTimeout(function(){
                    $(".input-text").val("");
                    $(".sy-step-2").removeAttr("hidden");
                    $(".input-bottom").css("display","none");
                    $(".user-step-2").removeAttr("hidden");
                },1000);
                setNumber++;     
            }else if(setNumber==1){  //时间
                time = $("#time").val();
                $(".user-step-2 #time").remove();
                $(".user-step-2 .conditions-input").remove();
                $(".user-step-2 p").html(time);
                setTimeout(function(){
                    $(".sy-step-3").removeAttr("hidden");
                    $(".sy-step-3").css("margin-bottom","20px");
                },1000);
            }
        }
      
    });

    $(".type-list li a").click(function(){     //喜好选择
        if($(this).hasClass("like-active")){
            $(this).removeClass("like-active");
        }else{
            $(this).addClass("like-active");
        }
    });

    $(".button-sure").click(function(){ //确定喜好选择选择,形成数组
        $(".like-active").each(function(){
            likeType.push($(this).html());
        });
        $(".like-sure").css("display","none");
        $(".am-modal-loading").modal('open');
        $.ajax(
            {
                type:"POST",
                url:"getCondition",
                dataType:"json",
                success: function(data){
                    window.location.href = "recommendLine";
                },
                error:function(){
                    alert("出错了！");
                }
            }
        );

    });

    $(".button-change").click(function(){ //更换喜好列表
        var num = 0;
        $(".type-list li a").each(function(){
            $(this).html("");
            $(this).html(newLikeType[num]);
            num++;
        });
    });
});

